import java.util.*;


public class mubang
{
	public static int maxCover(int a[], int L)
	{
		int n = a.length;
		int count=2;
		int maxCount=1;
		int start=0;
		int i=0,j=1;

		while(i<n && j<n)
		{
			while(j<n && (a[j]-a[i]<=L))
			{
				j++;
				count++;
			}
			j--; //退回到满足条件的j
			count--;
			if(maxCount<count)
			{
				start=i;
				maxCount=count;
			}
			i++;
			j++;
		}
		System.out.println("covered point:");
		for(i=start; i<start+maxCount; i++)
		{
			System.out.print(a[i]+" ");
		}
		System.out.println();
		return maxCount;
	}

	public static void main(String[] args)
	{
		int L = 8;
		int a[] = {1,2,3,4,5,100,1000};
		System.out.println("L="+L);
		System.out.println("max count:"+maxCover(a,L));
	}
}
